package hexgame;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class PlayMethods {
	static Map<String, PlayerFactory> methods;
	
	// Static constructor
	static {
		methods = new HashMap<String, PlayerFactory>();
	}
	
	public static void registerMethod(String name, PlayerFactory factory) {
		methods.put(name, factory);
	}
	
	public static Map<String, PlayerFactory> getMethods() {
		return methods;
	}
	
	public static String getPlayerFactoryName(PlayerFactory playerFactory) {
		String name = null;
		for (Entry<String, PlayerFactory> factory : methods.entrySet()) {
			if (playerFactory.equals(factory.getValue())) {
				name = factory.getKey();
			}
		}
		return name;
	}
}
